package com.neusoft.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@Configuration
@EnableWebMvc  //启动WebMvc相关功能
@ComponentScan({"com.neusoft.controller","com.neusoft.config","com.neusoft.exception"})
public class SpringMvcConfig{
    /*文件上传配置*/
    @Bean(name = "multipartResolver")
    public CommonsMultipartResolver multipartResolver(){
        CommonsMultipartResolver commonsMultipartResolver = new CommonsMultipartResolver();
        commonsMultipartResolver.setDefaultEncoding("UTF-8");
        commonsMultipartResolver.setMaxUploadSize(10*1024*1024);//一次请求上传最大字节数
        commonsMultipartResolver.setMaxInMemorySize(10240);//单个文件上传的最大字节数
        return commonsMultipartResolver;
    }
}
